import request from '@/utils/request'

/**
 * 查询车辆列表
 * @param {Object} query - 查询参数，包括分页、筛选条件等
 * @returns {Promise} - 返回车辆数据和分页信息
 */
export function listVehicle(query) {
    return request({
        url: '/delivery/vehicle/list',
        method: 'get',
        params: query,
    });
}

/**
 * 新增车辆
 * @param {Object} data - 新增的车辆信息
 * @returns {Promise} - 返回新增操作结果
 */
export function addVehicle(data) {
    return request({
        url: '/delivery/vehicle',
        method: 'post',
        data,
    });
}

/**
 * 更新车辆信息
 * @param {Object} data - 要更新的车辆信息
 * @returns {Promise} - 返回更新操作结果
 */
export function updateVehicle(data) {
    return request({
        url: '/delivery/vehicle',
        method: 'put',
        data,
    });
}

/**
 * 删除车辆
 * @param {String} vehicleNo - 要删除的车辆编号
 * @returns {Promise} - 返回删除操作结果
 */
export function deleteVehicle(vehicleNo) {
    return request({
        url: `/delivery/vehicle/delete/${vehicleNo}`,
        method: 'delete',
    });
}

/**
 * 批量删除车辆
 * @param {String[]} vehicleNos - 要删除的车辆编号列表
 * @returns {Promise} - 返回删除操作结果
 */
export function deleteVehicles(vehicleNos) {
    return request({
        url: '/delivery/vehicle/batchDelete',
        method: 'post',
        data: vehicleNos,
    });
}

/**
 * 获取车辆位置信息
 * @returns {Promise} - 返回车辆位置信息
 */
export function getVehicleLocation() {
    return request({
        url: `/delivery/vehicle/location`,
        method: 'get',
    });
}

/**
 * 获取全部车辆
 * @returns {Promise} - 返回全部车辆
 */
export function getAllVehicle() {
    return request({
        url: `/delivery/vehicle/all`,
        method: 'get',
    });
}